import { BasicColumn } from '/@/components/Table'
import { FormSchema } from '/@/components/Table'
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '模板名称',
    align: 'center',
    dataIndex: 'name',
  },
  {
    title: '模板编码',
    align: 'center',
    sorter: true,
    dataIndex: 'key',
  },
  {
    title: '模板分类',
    align: 'center',
    dataIndex: 'category',
  },
  {
    title: '版本',
    align: 'center',
    dataIndex: 'version',
  },
  {
    title: '创建日期',
    align: 'center',
    sorter: true,
    dataIndex: 'createTime',
  },
]
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '模板名称',
    field: 'name',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: '模板Key',
    field: 'key',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: '模板分类',
    field: 'category',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'act_model_type',
    },
    //colProps: {span: 6},
  },
]
//表单数据
// @ts-ignore
export const formSchema: FormSchema[] = [
  {
    label: '模板名称',
    field: 'name',
    component: 'Input',
    dynamicRules: () => {
      return [{ required: true, message: '请输入模板名称!' }]
    },
  },
  {
    label: '模板Key',
    field: 'key',
    component: 'Input',
    dynamicRules: () => {
      return [{ required: true, message: '请输入模板编码!' }]
    },
  },
  {
    label: '模板分类',
    field: 'category',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'act_model_type',
    },
    defaultValue: 'default',
    dynamicRules: () => {
      return [{ required: true, message: '请输入模板类型!' }]
    },
  },
  {
    label: '模板描述',
    field: 'description',
    component: 'InputTextArea',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
]

// @ts-ignore
export const deploySchema: FormSchema[] = [
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
  {
    label: '模板部署名称',
    field: 'name',
    component: 'Input',
    dynamicRules: () => {
      return [{ required: true, message: '请输入模板部署名称!' }]
    },
  },
]

export const xmlViewSchema: FormSchema[] = [
  {
    label: '',
    field: 'xmlContent',
    component: 'InputTextArea',
  },
]

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema
}
